﻿@model HelpDesk.Models.Ticket

@{
    ViewBag.Title = "Ticket# " + @Model.TicketID + " Details";
}

<link href="~/Content/DataTabblesBs.css" rel="stylesheet" />

@section Scripts {
    <script src="~/Scripts/jquery.dataTables.min.js"></script>
    <script src="~/Scripts/DataTablesBS.js"></script>

    <script>
        $(document).ready(function () {
            $('#Activities').dataTable();

        });



    </script>
}

<div class="span12">
    <p>
        &larr; @Html.ActionLink("Back to Ticket List", "Index")
    </p>
    <div class="well">
        <table class="table">
            <thead>
                <tr>
                    <th>
                        @Html.DisplayNameFor(model => model.Title)
                    </th>

                    <th>
                        @Html.DisplayNameFor(model => model.Created)
                    </th>
                    <th>Customer
                    </th>
                    <th>Assigned To
                    </th>
                    <th>Priority</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        @Html.DisplayFor(model => model.Title)
                    </td>

                    <td>
                        @Html.DisplayFor(model => model.Created)
                    </td>
                    <td>
                        @Html.DisplayFor(model => model.Customer.FirstName) @Html.DisplayFor(model => model.Customer.LastName)
                    </td>
                    <td>
                        @Html.DisplayFor(model => model.SupportStaff.FirstName) @Html.DisplayFor(model => model.SupportStaff.LastName)
                    </td>
                    <td><span class="label @Model.Priority.Color">@Html.DisplayFor(model => model.Priority.Priority)</span></td>
                    <td><span class="label @Model.Status.Color">@Html.DisplayFor(model => model.Status.Status)</span></td>
            </tbody>
        </table>
    </div>
   
    <div class="pull-right">
        <div class="btn-group">
             @if (Model.Status.Status.ToLower() != "closed")
             {
            <a href="@Url.Action("AddActivity", "Ticket", new { id = @Model.TicketID })" class="btn"><i class="icon-comment"></i> Add Commnet</a>
            <a class="btn" data-modal-url="@Url.Action("UploadFile", "Ticket", new { id = @Model.TicketID })" data-modal-show-footer="false" data-modal-header="Upload Files"><i class="icon-file"></i> Upload Files</a>
            <a class="btn btn-danger" data-modal-Text="Are you sure you want to close ticket# @Model.TicketID?" data-modal-show-footer="true" data-modal-header="Close Ticket" data-modal-url-action="@Url.Action("CloseTicket", "Ticket", new { id = @Model.TicketID })"><i class="icon-refresh"></i> Close Ticket</a>
                 
             }
            
        </div>
    </div>
   
    <div class="row">
        <div class="span12">&nbsp;</div>
    </div>
    <div class="row">
        <div class="span12">

            <ul class="nav nav-tabs" id="ActivitiesTab">
                <li class="active"><a href="#Descripton" data-toggle="tab">Descripton</a></li>
                <li><a href="#Comments" data-toggle="tab">Comments</a></li>
                <li><a href="#UploadedFiles" data-toggle="tab">Upload File</a></li>
            </ul>

            <div class="tab-content">
                <div class="tab-pane active" id="Descripton">
                    <fieldset>
                        <legend>Ticket Description</legend>
                        <textarea rows="10" class="span12"> @Model.Description</textarea>
                    </fieldset>
                </div>
                <div class="tab-pane" id="Comments">
                    <fieldset>
                        <legend>Ticket Activity</legend>
                        <table id="Activities" class="table table-striped table-hover">
                            <thead>
                                <tr>
                                    <th>Comment</th>
                                    <th>Posted On</th>
                                    <th>Posted By</th>
                                    <th>User Type</th>
                                </tr>
                            </thead>
                            <tbody class=":nth-child">
                                @foreach (HelpDesk.Models.Activity act in Model.Activities.OrderBy(m => m.Created))
                                {
                                    <tr>
                                        <td>
                                            @act.Text
                                        </td>
                                        <td>
                                            @act.Created.ToUniversalTime()
                                        </td>
                                        <td>
                                            @act.SubmittedBy.FirstName @act.SubmittedBy.LastName 
                                        </td>
                                        <td><span class="@(act.SubmittedBy.IsCustomer ? "label label-info" : "label label-inverse")">@(act.SubmittedBy.IsCustomer ? "(Customer)" : "(Staff)") </span></td>
                                    </tr>
                                }

                            </tbody>
                        </table>
                    </fieldset>
                </div>
                <div class="tab-pane" id="UploadedFiles">
                    <fieldset>
                        <legend>File Repository</legend>
                        dfdf
                    </fieldset>
                </div>
            </div>
        </div>
    </div>
</div>

@Html.Partial("_ModalBox")


